package com.fc.redis.service;

import com.fc.redis.entity.TbUser;
import com.fc.redis.mapper.TbUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.TimeUnit;

/**
 * Created By gao_e on 2020/3/29 13:58
 */
@Service
public class UserService3 implements IUserService3 {
    @Autowired
    private TbUserMapper tbUserMapper;
    public void addUserTest() {
        System.out.println("addUserTest");
    }
//    @Async
    public void testAsyn() {
        for (int i = 0; i < 100; i++) {
            System.out.println(i);
            try {
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    @Transactional
//    @Async
    public void addUsers() {
        tbUserMapper.insert(new TbUser("传智播客"));
        int i = 1/0;
        tbUserMapper.insert(new TbUser("黑马程序员"));
    }
}
